<template>
  <div class="app-container">
    <!--查询条件-->
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="120px">
      <el-form-item label="质检结果" prop="qmsDictQcResult">
        <el-select v-model="queryParams.qmsDictQcResult" placeholder="请选择质检结果" clearable filterable
                   style="width: 250px">
          <el-option
            v-for="dict in qcResultOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="质检日期">
        <el-date-picker
          v-model="queryParams.dtRange"
          style="width: 250px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="质检员" prop="attentionUserName">
        <el-select
          filterable
          v-model="queryParams.attentionUserName"
          placeholder="请选择质检员"
          clearable
          style="width: 250px"
        >
          <el-option
            v-for="item in qcWorkerList"
            :key="item.userId"
            :label="item.nickName"
            :value="item.nickName"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">

      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="showDialog_qc"
          v-hasPermi="['qms:qc:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['qms:qc:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['qms:qc:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
    </el-row>
    <!--列表-->
    <el-table v-loading="loading" :data="qcList" :highlight-current-row="true" stripe @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="50" align="center" fixed="left"/>
      <el-table-column type="expand">
        <template slot-scope="props">
          <el-form label-position="left" class="demo-table-expand">
            <el-form-item label="备注：">
              <span>{{ props.row.qcNote }}</span>
            </el-form-item>
            <el-form-item label="审核人：">
              <span>{{ props.row.confirmUserName }}</span>
            </el-form-item>
            <el-form-item label="审核结果：">
              <dict-tag :options="dict.type.oa_dict_confirm_status" :value="props.row.oaDictConfirmStatus"/>
            </el-form-item>
            <el-form-item label="审核时间：">
              <span>{{ props.row.confirmDt }}</span>
            </el-form-item>
            <el-form-item label="审核意见：">
              <span>{{ props.row.confirmNote }}</span>
            </el-form-item>
          </el-form>
        </template>
      </el-table-column>
      <el-table-column label="质检时间" align="center" prop="docDt" width="180"/>
      <el-table-column label="质检号" align="center" prop="docNum" width="150"/>
      <el-table-column label="工序类型" align="center" prop="mesDictProcessType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.mes_dict_process_type" :value="scope.row.mesDictProcessType"/>
        </template>
      </el-table-column>

      <el-table-column label="工序名称" align="center" prop="mesDictProcessName">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.mes_dict_process_name" :value="scope.row.mesDictProcessName"/>
        </template>
      </el-table-column>

      <el-table-column label="工序内容" align="center" prop="processContent" width="120" :show-overflow-tooltip="true"/>

      <el-table-column label="工序符号" align="center" prop="mesDictProcessCode">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.mes_dict_process_code" :value="scope.row.mesDictProcessCode"/>
        </template>
      </el-table-column>

      <el-table-column label="物料名称" align="center" prop="itemName" width="150" :show-overflow-tooltip="true"/>
      <el-table-column label="物料编码" align="center" prop="itemNum" width="180"/>
      <el-table-column label="规格" align="center" prop="itemSpecification" width="120"/>

      <el-table-column label="质检数量" align="center" prop="qcQuantity"/>
      <el-table-column label="合格数量" align="center" prop="qcPassQty"/>
      <el-table-column label="超差品数量" align="center" prop="poorQty" width="120"/>
      <el-table-column label="废品数量" align="center" prop="wasteQty"/>
      <el-table-column label="不合格数量" align="center" prop="failQuantity" width="120"/>


      <el-table-column label="合格率(%)" align="center" prop="percentOfPass">
        <template slot-scope="scope">
          {{ fun(scope.row.percentOfPass) }}
        </template>
      </el-table-column>

      <el-table-column label="计量单位" align="center" prop="wmsDictMeasuringUnit" width="100">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.wms_dict_measuring_unit" :value="scope.row.wmsDictMeasuringUnit"/>
        </template>
      </el-table-column>
      <el-table-column label="质检员" align="center" prop="attentionUserName"/>


      <el-table-column label="完工号" align="center" prop="doneDocNum" width="150">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="show_done(scope.row)"
          >{{scope.row.doneDocNum}}<i class="el-icon-caret-right"></i>
          </el-button>
        </template>
      </el-table-column>

      <el-table-column label="审核状态" align="center" prop="oaDictConfirmStatus" v-if="columns[23].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.oa_dict_confirm_status" :value="scope.row.oaDictConfirmStatus"/>
        </template>
      </el-table-column>

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="showDialog_qc(scope.row)"
            v-hasPermi="['qms:qc:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['crm:crmOrders:remove']"
            :disabled="scope.row.oaDictConfirmStatus !='editing'">删除
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-success"
            @click="showDialog_confirm(scope.row)"
            v-hasPermi="['oa:confirm:edit']"
            :disabled="scope.row.oaDictConfirmStatus !='waiting'"> 审核
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <!--分页-->
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改质量检查对话框 -->
    <el-dialog v-dialogDrag v-dialogDragWidth :title="title" :visible.sync="open" width="800px" append-to-body :close-on-click-modal=false>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">

        <el-alert v-show="form.oaDictConfirmStatus != 'editing'"
                  style="margin-bottom: 15px;"
                  :title="form.latestTaskInfo"
                  type="info"
                  :closable="false"
                  effect="dark"
        >
        </el-alert>

        <el-tabs>
            <el-row>
              <el-col :span="12">
                <el-form-item label="质检号" prop="docNum">
                  <el-input v-model="form.docNum"

                            placeholder="请输入质检号"
                            clearable filterable
                            :style="{width: '100%'}" @blur="trimOnBlur"/>
                </el-form-item>
              </el-col>

              <el-col :span="12">
                <el-form-item label="质检时间" prop="docDt">
                  <el-date-picker clearable size="small"
                                  v-model="form.docDt"
                                  type="datetime"
                                  placeholder="选择质检时间"

                                  :style="{width: '100%'}" clearable filterable>
                  </el-date-picker>
                </el-form-item>
              </el-col>

              <el-col :span="12">
                <el-form-item label="检查数量" prop="qcQuantity">
                  <el-input-number v-model="form.qcQuantity"

                                   clearable filterable
                                   placeholder="请输入检查数量"
                                   :style="{width: '100%'}"
                                   @blur="trimOnBlur"/>
                </el-form-item>
              </el-col>

              <el-col :span="12">
                <el-form-item label="不合格数量" prop="failQuantity">
                  <el-input-number v-model="form.failQuantity"
                                   clearable
                                   filterable placeholder="请输入不合格数量"
                                   :style="{width: '100%'}"
                                   @blur="trimOnBlur"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="合格数量" prop="qcPassQty">
                  <el-input-number v-model="form.qcPassQty"
                                   clearable
                                   filterable placeholder="请输入合格数量"
                                   :style="{width: '100%'}"
                                   @blur="trimOnBlur"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="超差品数量" prop="poorQty">
                  <el-input-number v-model="form.poorQty"
                                   clearable
                                   filterable placeholder="请输入超差品数量"
                                   :style="{width: '100%'}"
                                   @blur="trimOnBlur"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="废品数量" prop="wasteQty">
                  <el-input-number v-model="form.wasteQty"
                                   clearable
                                   filterable placeholder="请输入废品数量"
                                   :style="{width: '100%'}"
                                   @blur="trimOnBlur"/>
                </el-form-item>
              </el-col>

              <el-col :span="12">
                <el-form-item label="质检员" prop="fkAttentionUserId">
                  <el-input v-model="form.fkAttentionUserId" v-show="false"/>
                  <el-input placeholder="请点击右侧按钮选择质检员" readOnly="true" v-model="form.qcUserName"
                            class="input-with-select">
                    <el-button @click="showDialog_selectQc" slot="append" icon="el-icon-search"
                    ></el-button>
                  </el-input>
                </el-form-item>

              </el-col>

              <!--<el-col :span="12">
                <el-form-item label="加入">
                  <el-select v-model="form.sysYesNoToFailList" placeholder="请选择" :style="{width: '100%'}">
                    <el-option value="合格"/>
                    <el-option value="不合格品"/>
                    <el-option value="超差品"/>
                    <el-option value="废品"/>
                  </el-select>
                </el-form-item>
              </el-col>-->

              <el-col :span="24">
                <el-form-item label="备注" prop="qcNote">
                  <el-input v-model="form.qcNote" type="textarea" @blur="trimOnBlur"
                            autosize clearable filterable
                            placeholder="请输入备注" :style="{width: '100%'}"/>
                </el-form-item>
              </el-col>
            </el-row>

        </el-tabs>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm" :disabled="form.oaDictConfirmStatus != 'editing'">确 定</el-button>
        <el-button type="warning" @click="submitForm('waiting')" :disabled="form.oaDictConfirmStatus != 'editing'">提交待审
        </el-button>
          <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!--引用组件-->
    <confirm ref="component_confirm" @ok="confirm_done"/>
    <select-user ref="component_selectQc" @ok="selectQc_done"/>
    <select-user ref="component_selectWorker" @ok="selectWorker_done"/>
    <select-user ref="component_selectAttentionUser" @ok="selectAttentionUser_done"/>

  </div>
</template>

<script>
  import {listQc, getQc, delQc, addQc, updateQc} from "@/api/qms/qc";
  import selectDone from "../../mes/done/selectDone";
  import {listUserGroup} from "@/api/comn/userGroup";
  import confirm from "../../oa/confirm";
  import {trimOnBlur} from '@/utils/form'
  import {parseTime} from '@/utils/ruoyi'
  import selectUser from "../../comn/userGroup/selectUser";

  export default {
    name: "Qc",
    dicts: ['qms_dict_qc_type', 'qms_dict_qc_result', 'sys_yes_no', 'mes_dict_process_type', 'mes_dict_process_name',
      'mes_dict_process_code', 'sys_normal_disable', 'oa_dict_confirm_status', 'wms_dict_measuring_unit'],
    components: {selectDone, selectUser, confirm},
    data() {
      return {
        fold_form_to_done: 'false',
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        //是否加入不合格品下拉
        failListOptions: [],
        //质检结果下拉
        qcResultOptions: [],
        //工人列表
        mesJobDoneWorkersList: [],
        //质检员下拉
        qcWorkerList: [],
        // 质量检查表格数据
        qcList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          fkDispatchUuid: null,
          qmsDictQcType: null,
          qcQuantity: null,
          failQuantity: null,
          sysYesNoToFailList: null,
          qcDt: null,
          fkUserId: null,
          qmsDictQcResult: null,
          qcNote: null,
          sysNormalDisable: null,
          selectedDone: null,
          fkMesWorkUuid: null,
          docTitle: null,
          docNum: null,
          docDt: null,
          docNote: null,
          fkAttentionUserId: null,
          qcNickName: null,
          fkConfirmUserId: null,
          confirmDt: null,
          oaDictConfirmStatus: null,
          confirmNote: null,
          dateRange: null,
        },
        // 表单参数
        form: {
          selectedDone: null,
          fkMesWorkUuid: null,
        },
        // 表单校验
        rules: {
          qcQuantity: [
            {required: true, message: "请输入检查数量", trigger: "change"}
          ],
          sysYesNoToFailList: [
            {required: true, message: "是否加入不合格品管理不能为空", trigger: "change"}
          ],
          qmsDictQcResult: [
            {required: true, message: "请选择质检结果", trigger: "change"}
          ],
          sysNormalDisable: [
            {required: true, message: "状态不能为空", trigger: "change"}
          ],
          docNum: [
            {required: true, message: "请选择单据编号", trigger: "change"}
          ],
          docDt: [
            {required: true, message: "请选择质检时间", trigger: "change"}
          ],
          fkAttentionUserId: [
            {required: true, message: "请选择质检员", trigger: "change"}
          ],
          fkMesWorkUuid: [
            {required: true, message: "请选择完工汇报", trigger: "change"}
          ],
          qmsDictQcType: [
            {required: true, message: "请选择质检类型", trigger: "change"}
          ],
        },
        columns: [
          {key: 0, label: `单据编号`, visible: true},
          {key: 1, label: `物料名称`, visible: true},
          {key: 2, label: `质检时间`, visible: true},
          {key: 3, label: `生产数量`, visible: true},
          {key: 4, label: `工序类型`, visible: true},
          {key: 5, label: `工序名称`, visible: true},
          {key: 6, label: `工序符号`, visible: true},
          {key: 7, label: `计划数量`, visible: true},
          {key: 8, label: `计划班组`, visible: true},
          {key: 9, label: `计划负责人`, visible: true},
          {key: 10, label: `计划开始时间`, visible: true},
          {key: 11, label: `计划完工时间`, visible: true},
          {key: 12, label: `实际数量`, visible: true},
          {key: 13, label: `实际班组`, visible: true},
          {key: 14, label: `实际负责人`, visible: true},
          {key: 15, label: `实际开始时间`, visible: true},
          {key: 16, label: `实际完工时间`, visible: true},
          {key: 17, label: `质检类型`, visible: true},
          {key: 18, label: `检查数量`, visible: true},
          {key: 19, label: `不合格数量`, visible: true},
          {key: 20, label: `加入不合格品`, visible: true},
          {key: 21, label: `质检员`, visible: true},
          {key: 22, label: `质检结果`, visible: true},
          {key: 23, label: `审核状态`, visible: true}
        ],
      };
    },
    created() {
      this.getList();
      this.getList_qcWorker();
      /**获取质检结果字典表数据*/
      this.getDicts("qms_dict_qc_result").then(response => {
        this.qcResultOptions = response.data
      });
    },
    methods: {
      inputChange() {
        if (this.form.doneQty != null && this.form.quotaQtyMin != null)
          this.form.totalQuotaQtyMin = this.form.doneQty * this.form.quotaQtyMin
      },

      fun(val) {
        return Number(val).toFixed(2);
      },
      trimOnBlur,
      /** 打开对话框：审核 */
      showDialog_confirm(row) {
        let obj = {
          tableName: 'qms_qc',
          uuidColumn: 'qc_uuid',
          fkUuid: row.qcUuid,
          attentionUserNickName: row.attentionUserName,
          oaDictConfirmStatus: row.oaDictConfirmStatus,
          msg: `请审核质检单, 质检号：${row.docNum}`
        }
        this.$refs.component_confirm.showDialog_confirm(obj);

      },

      /** 查询质量检查列表 */
      getList() {
        this.loading = true;
        if (this.queryParams.dtRange) {
          this.queryParams.dtRangeBegin = this.queryParams.dtRange[0]
          this.queryParams.dtRangeEnd = this.queryParams.dtRange[1]
        } else {
          this.queryParams.dtRangeBegin = null
          this.queryParams.dtRangeEnd = null
        }
        listQc(this.queryParams).then(response => {
          this.qcList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },

      getList_qcWorker() {
        listUserGroup({comnDictUserGroup: 'quality_checker'}).then(response => {
          this.qcWorkerList = response.rows
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          qcUuid: null,
          fkDispatchUuid: null,
          qmsDictQcType: null,
          sysYesNoToFailList: '合格',
          qcDt: null,
          nickName: null,
          fkUserId: null,
          qmsDictQcResult: null,
          qcNote: null,
          sysNormalDisable: null,
          selectedDone: null,
          fkMesWorkUuid: null,
          docTitle: null,
          docNum: null,
          docDt: parseTime(Date.now(), '{y}-{m}-{d} {h}:{i}:{s}'),
          docDtDone: parseTime(Date.now(), '{y}-{m}-{d} {h}:{i}'),
          docNote: null,
          fkAttentionUserId: null,
          fkConfirmUserId: null,
          confirmDt: null,
          oaDictConfirmStatus: null,
          confirmNote: null,
          qcNickName: null,
          mes_dict_process_name: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.queryParams.dateRange = [];
        this.resetForm("queryForm");
        this.handleQuery();
      },
      /**多选框选中数据*/
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.qcUuid)
        this.docDts = selection.map(item => item.docDt)
        this.docNums = selection.map(item => item.docNum)
        this.single = selection.length !== 1
        this.oaDictConfirmStatus = selection.map(i => i.oaDictConfirmStatus)
        let editing = 'editing';
        this.multiple =
          (this.oaDictConfirmStatus.indexOf(editing) > -1 && [...new Set(this.oaDictConfirmStatus)] == editing) ? false : true
      },
      /** 新增按钮操作 */
      /*handleAdd() {
        this.reset();

        newDocNum({preCode: 'QMS-', len: 12}).then(response => {
          this.form.docNum = response.msg
          console.log(this.form.docNum)
        })

        this.form.oaDictConfirmStatus = 'editing'
        this.open = true;
        this.title = "添加检验管理";
        this.$msgbox("新增功能待实现,目前质检单由完工汇报质检生成！")
      },*/
      /** 修改按钮操作 */
      showDialog_qc(row) {
        this.reset();
        const qcUuid = row.qcUuid || this.ids
        getQc(qcUuid).then(response => {
          this.form = response.data;
          console.log(this.form)

          this.form.oaDictConfirmStatus =
            ('editing' == this.form.oaDictConfirmStatus || 'reject' == this.form.oaDictConfirmStatus)
              ? 'editing' : this.form.oaDictConfirmStatus


          if(row.oaDictConfirmStatus!='editing'||row.oaDictConfirmStatus!='reject'||this.oaDictConfirmStatus!='editing'||this.oaDictConfirmStatus!='reject'){
            this.form.latestTaskInfo='💡 该条记录审核状态为'+
              this.selectDictLabel(this.dict.type.oa_dict_confirm_status, row.oaDictConfirmStatus||this.oaDictConfirmStatus)+'状态'+','+'不能修改'
          }

          this.open = true;
          this.title = "修改质量检查";
          this.form.selectedWork = `加工号：${this.form.doneDocNum},物料名称：${this.form.itemName},工序名称：${this.selectDictLabel(this.dict.type.mes_dict_process_name, this.form.mesDictProcessName)}`
          this.form.qcUserName = `${this.form.attentionUserName}（ID：${this.form.fkAttentionUserId}）`
        });
      },
      /** 提交按钮 */
      submitForm(confirmStatus) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if(confirmStatus=='waiting') this.form.oaDictConfirmStatus = confirmStatus
            if (this.form.qcUuid != null) {
              updateQc(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              this.form.mesJobDoneWorkersList = this.mesJobDoneWorkersList;
              addQc(this.form).then(response => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });

            }
          }
        });
      },
      // submit_confirm() {
      //   this.form.oaDictConfirmStatus = 'waiting'
      //   updateQc(this.form).then(response => {
      //     this.$modal.msgSuccess("提交待审成功");
      //     this.open = false;
      //     this.getList();
      //   });
      // },

      /** 删除按钮操作 */
      handleDelete(row) {
        const qcUuids = row.qcUuid || this.ids;
        const docDts = row.docDt || this.docDts;
        const docNums = row.docNum || this.docNums;
        this.$confirm('是否确认删除质检时间为"' + docDts + '",质检号为"' + docNums + '"的质检单？', '删除确认', {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function () {
          return delQc(qcUuids);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {
        });
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('qms/qc/export', {
          ...this.queryParams
        }, `qms_qc.xlsx`)
      },

      /** 选择经办人 */
      showDialog_selectQc(form) {
        this.currentForm = form
        this.$refs.component_selectQc.userGroup = 'quality_checker';
        this.$refs.component_selectQc.show();
      },
      /** 选择经办人 - 完成 */
      selectQc_done(user) {
        this.currentForm.fkAttentionUserId = user.userId
        this.currentForm.qcUserName = user.userNickNameAndId
      },

      function() {
        const btn = document.getElementById('btn');
        btn.onmouseover = function () {
          $("#btn").addClass('btn-info');
        };
        btn.onmouseout = function () {
          $("#btn").removeClass('btn-info')
        };
      },
      confirm_done() {
        this.getList()
      },

      // 显示 - 销售号
      show_done(r) {
        console.log(r)
        this.$router.push(`/mes/done/docNum/${r.doneDocNum}`);
      },

      /** 完工汇报（工人、工时）序号 */
      rowMesJobDoneWorkersIndex({row, rowIndex}) {
        row.index = rowIndex + 1;
      },
      /** 完工汇报（工人、工时）添加按钮操作 */
      handleAddMesJobDoneWorkers() {
        let obj = {};
        obj.orderNum = "";
        obj.fkUserIdWorker = "";
        obj.quotaWorkingHours = "";
        obj.workingHours = "";
        obj.workerName = "";
        this.mesJobDoneWorkersList.push(obj);
      },
      /** 完工汇报（工人、工时）删除按钮操作 */
      handleDeleteMesJobDoneWorkers() {
        if (this.checkedMesJobDoneWorkers.length == 0) {
          this.$modal.msgError("请先选择要删除的完工汇报（工人、工时）数据");
        } else {
          const mesJobDoneWorkersList = this.mesJobDoneWorkersList;
          const checkedMesJobDoneWorkers = this.checkedMesJobDoneWorkers;
          this.mesJobDoneWorkersList = mesJobDoneWorkersList.filter(function (item) {
            return checkedMesJobDoneWorkers.indexOf(item.index) == -1
          });
        }
      },
      /** 复选框选中数据 */
      handleMesJobDoneWorkersSelectionChange(selection) {
        this.checkedMesJobDoneWorkers = selection.map(item => item.index)
      },
      /** 显示对话框：选择工人 */
      showDialog_selectWorker(scope) {
        this.currRowScope = scope
        this.$refs.component_selectWorker.userGroup = 'worker';
        this.$refs.component_selectWorker.show();
      },

      /** 选择工人 - 完成 */
      selectWorker_done(user) {
        this.currRowScope.row.fkUserIdWorker = user.userId
        this.currRowScope.row.workerName = user.userNickNameAndId
      },
      /** 选择经办人 */
      showDialog_selectAttentionUser(form) {
        this.currentForm = form
        this.$refs.component_selectAttentionUser.userGroup = 'worker';
        this.$refs.component_selectAttentionUser.show();
      },
      /** 选择经办人 - 完成 */
      selectAttentionUser_done(user) {
        this.currentForm.fkUserId = user.userId
        this.currentForm.attentionUserName = user.userNickNameAndId
      },


    }
  };
</script>
